This section is a detailed description for configuring Sound Blaster 16 from source. I you have a binary and all you need to know is what to put in your .bochsrc file, see keyword sb16 in the bochsrc section.
Sound Blaster 16 (SB16) emulation for Bochs was written and donated by Josef Drexler, who has a web page on the topic. The entire set of his SB16 patches have been integrated into Bochs, however, so you can find everything you need here.
SB16 Emulation has been tested with several soundcards and versions of Linux. Please give Josef feedback on whether is does or doesn't work on your combination of software and hardware.
Right now, MPU401 emulation is next to perfect. It supports UART and SBMIDI mode, because the SB16's MPU401 ports can't do anything else as well.
The digital audio basically works, but the emulation is too slow for fluent output unless the application doesn't do much in the background (or the foreground, really). The sound tends to looping or crackle on slower computer, but the emulation appears to be correct. Even a MOD player works, although only for lower sampling speeds.
Also, the MIDI data running through the MPU401 ports can be written into a SMF, that is the standard midi file. The wave output can be written into a VOC file, which has a format defined by Creative Labs. This file format can be converted to WAV by sox for example.
Output is supported on Linux and Windows 95 at the moment. On Linux, the output goes to any file or device. If you have a wavetable synthesizer, midi can go to /dev/midi00, otherwise you may need a midi interpreter. For example, the midid program from the DosEmu project would work. Wave output should go to /dev/dsp. These devices are assumed to be OSS devices, if they're not some of the ioctl's might fail. On Windows, midi and output goes to the midi mapper and the wave mapper, respectively. A future version might have selectable output devices.
Prerequisites:
A wavetable synthesizer on /dev/midi00 and a working /dev/dsp if you want real time music and sound, otherwise output to midi and wave files is also possible. Optionally, you can use a software midi interpreter, such as the midid program from the DosEmu project instead of /dev/midi00.
There are a few values in config.h that are relevant to the sound functions. Edit config.h after running configure, but before compiling.
BX_USE_SB16_SMF should be 1 unless you intend to have several sound cards running at the same time.
BX_USE_SOUND_VIRTUAL can be 0 or 1, and determines whether the output class uses virtual functions or not. The former is more versatile and allows to select the class at runtime (not supported at the moment), while the latter is slightly faster.
BX_SOUND_OUTPUT_C is the name of the class used for output. The default is to have no output functions, so you need to change this if you want any sound. The following are supported at the moment:
bx_sound_linux_c for output to /dev/dsp and /dev/midi00 on Linux (and maybe other OSes that use the OSS driver) bx_sound_windows_c for output to the midi and wave mapper of Windows 3.1 and higher. bx_sound_output_c for no output at all. |
Setup the SB16 emulation in your .bochsrc, according to instructions in that file.
The source for the SB16CTRL program that is used to modify the runtime behaviour of the SB16 emulator is included in misc/sb16. You can compile it or download the executable.
misc/sb16/ contains a C program that can be run inside the emulator, and the executable for DOS. It currently supports the following commands:
-i number shows the selected emulator info string, e.g. sb16ctrl -i 3 to show how many patch translations are active -t six numbers loads a translation into the translation table. The numbers are: OldBankMSB,OldBankLSB,OldProgram,NewBankMSB,NewBankLSB,NewProgram All values can be 0..127 or 255. 255 for Old values means match any and for New values means don't change, e.g. sb16ctrl -t 255,255,0,255,255,32 to change patch 0 (Piano) to patch 32 (Acoustic Bass) -r Reset the patch translation table e.g. sb16ctrl -r -m some numbers Upload the given numbers to the midi output device. Note that it should be a complete midi message, and also that it is subject to patch translation. e.g. sb16ctrl -m 0x80,64,0 to send a note-off message to channel 0. -f filename Reads in a file and executes the commands in it. These have the same format as the above commands, except that they don't have the dash "-" in front of them. Comment lines are supported and start with a hash sign "#". -h Show a brief summary of the commands. |
All numbers can be valid parameters to the strtol() function, so hex and octal notation is fine. They have to be delimited by either commas "," or slashes "/", spaces are not allowed.
The command line can have any number of commands. However, if none are given, "-f -" is assumed, which means commands are taken from stdin.